#
# @lc app=leetcode.cn id=1437 lang=python
#
# [1437] 是否所有 1 都至少相隔 k 个元素
#

# @lc code=start
class Solution(object):
    def kLengthApart(self, nums, k):
        """
        :type nums: List[int]
        :type k: int
        :rtype: bool
        """
        start = False
        zero_count = 0
        for num in nums:
            if num == 0:
                zero_count += 1
            else:
                if zero_count <k and start:
                    return False
                else:
                    start = True
                    zero_count = 0
        return True
# @lc code=end

